<%@ page import="com.cinsea.htmlselect.service.OptionService" %>
<%@ page import="com.cinsea.common.Env" %>
<%@ page import="java.util.List" %>
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ include file="/common/common.jsp" %>
<%
    String processid=StringUtil.null2String(request.getParameter("processid"));
    //测试用processid="f2d1fb3e2d2d8113012d2d919edd0007";
    String teacherSql="select b.processid as id,b.name from ut_trainningcontent a,ut_teacher b where a.teacher=b.processid and iskp=1 and a.processid=?";
    JdbcDao jdbcDao=(JdbcDao)Env.getBean("jdbcDao");
    List teachers=jdbcDao.queryForList(teacherSql,new Object[]{processid}) ;
    String kc="、关于课程内容";
    String js="、讲师";
    String jx="、关于教学服务";
    String xy="、学员的感受";
    List<Option> kcOptions=optionService.getOptions("8a00010f2d5e315a012d72e0caaf01eb",null);
    List<Option> jsOptions=optionService.getOptions("8a00010f2d5e315a012d72e1601901ec",null);
    List<Option> jxOptions=optionService.getOptions("8a00010f2d5e315a012d72e19a0601ed",null);
    List<Option> xyOptions=optionService.getOptions("8a00010f2d5e315a012d72e1d76c01ee",null);
    int i =1;
    pagemenustr += "addBtn(tb,'保存','S','disk',function(){document.getElementById('mainform').submit()});";
    pagemenustr += "addBtn(tb,'返回','R','arrow_redo',function(){location='scoreview.jsp?processid="+processid+"'});";
    String kpiSql="";
    String k1="";
    String k2="";
    String k3="";
    String k4="";
    String k5="";
    String k6="";
%>
<html>
<head>
    <%@ include file="/common/head.jsp" %>
    <script type="text/javascript">
       Ext.onReady(function() {
            <%if(!pagemenustr.equals("")){%>
            var tb = new Ext.Toolbar();
            tb.render('pagemenubar');
            <%=pagemenustr%>
            <%}%>
       } )
    </script>
    <style>
        .scoretable {border:1px solid #000}
    </style>
</head>
<body>
<div id="pagemenubar" style="z-index:100;"></div>
<form id='mainform' action="scoreop.jsp" method="post">
<input type=hidden id=processid name=processid value='<%=processid%>'>
<div>参加调查人总数：<input id='k6' name='k6'></div>
<table class="scoretable"  width="100%">
    <colgroup>
        <col width="50%">
        <col width="10%">
        <col width="10%">
        <col width="10%">
        <col width="10%">
        <col width="10%">
    </colgroup>
    <tr>
        <td>指标</td>
        <td>很好</td>
        <td>好</td>
        <td>一般</td>
        <td>差</td>
        <td>很差</td>
    </tr>
    <tr bgcolor="graytext">
        <td><%=i+++kc%></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
    </tr>
    <%for(Option kcOption:kcOptions){
    kpiSql="select * from ut_kpiscore where prjid=? and kid=?";
        List data=jdbcDao.queryForList(kpiSql,new Object[]{processid,kcOption.getId()});
        if (data.size()>0){
            k1= ((Map)data.get(0)).get("k1")==null?"" :((Map)data.get(0)).get("k1").toString();
            k2= ((Map)data.get(0)).get("k2")==null?"" :((Map)data.get(0)).get("k2").toString();
            k3= ((Map)data.get(0)).get("k3")==null?"" :((Map)data.get(0)).get("k3").toString();
            k4= ((Map)data.get(0)).get("k4")==null?"" :((Map)data.get(0)).get("k4").toString();
            k5= ((Map)data.get(0)).get("k5")==null?"" :((Map)data.get(0)).get("k5").toString();
            k6= ((Map)data.get(0)).get("k6")==null?"" :((Map)data.get(0)).get("k6").toString();

        }
    %>
    <tr>
        <td><%=kcOption.getObjname()%></td>
        <td><input id='k1_<%=kcOption.getId()%>' name='k1_<%=kcOption.getId()%>' value="<%=k1%>"></td>
        <td><input id='k2_<%=kcOption.getId()%>' name='k2_<%=kcOption.getId()%>'value="<%=k2%>"></td>
       <td><input id='k3_<%=kcOption.getId()%>' name='k3_<%=kcOption.getId()%>' value="<%=k3%>"></td>
       <td><input id='k4_<%=kcOption.getId()%>' name='k4_<%=kcOption.getId()%>' value="<%=k4%>"></td>
        <td><input id='k5_<%=kcOption.getId()%>' name='k5_<%=kcOption.getId()%>' value="<%=k5%>"></td>
    </tr>
    <%} %>

   <%for(Object t:teachers){
       String tid=((Map)t).get("id").toString();
       String tname= ((Map)t).get("name").toString();
   %>
    <tr bgcolor="graytext">
        <td><%=i+++js+tname%></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
    </tr>
    <% for(Option jsOption:jsOptions){
    kpiSql="select * from ut_kpiscore where prjid=? and teacherid=? and  kid=?";
        List data=jdbcDao.queryForList(kpiSql,new Object[]{processid,tid,jsOption.getId()});
        if (data.size()>0){
            k1= ((Map)data.get(0)).get("k1")==null?"" :((Map)data.get(0)).get("k1").toString();
            k2= ((Map)data.get(0)).get("k2")==null?"" :((Map)data.get(0)).get("k2").toString();
            k3= ((Map)data.get(0)).get("k3")==null?"" :((Map)data.get(0)).get("k3").toString();
            k4= ((Map)data.get(0)).get("k4")==null?"" :((Map)data.get(0)).get("k4").toString();
            k5= ((Map)data.get(0)).get("k5")==null?"" :((Map)data.get(0)).get("k5").toString();
            k6= ((Map)data.get(0)).get("k6")==null?"" :((Map)data.get(0)).get("k6").toString();

        }
    %>
    <tr>
        <td><%=jsOption.getObjname()%></td>
        <td><input id='k1_<%=jsOption.getId()%>_<%=tid%>' name='k1_<%=jsOption.getId()%>_<%=tid%>' value="<%=k1%>"></td>
        <td><input id='k2_<%=jsOption.getId()%>_<%=tid%>' name='k2_<%=jsOption.getId()%>_<%=tid%>' value="<%=k2%>"></td>
        <td><input id='k3_<%=jsOption.getId()%>_<%=tid%>' name='k3_<%=jsOption.getId()%>_<%=tid%>' value="<%=k3%>"></td>
        <td><input id='k4_<%=jsOption.getId()%>_<%=tid%>' name='k4_<%=jsOption.getId()%>_<%=tid%>' value="<%=k4%>"></td>
        <td><input id='k5_<%=jsOption.getId()%>_<%=tid%>' name='k5_<%=jsOption.getId()%>_<%=tid%>' value="<%=k5%>"></td>
    </tr>
    <%}%>
    <%}%>

    <tr bgcolor="graytext">
        <td><%=i+++jx%></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
    </tr>
    <%for(Option jxOption:jxOptions){
    kpiSql="select * from ut_kpiscore where prjid=? and kid=?";
        List data=jdbcDao.queryForList(kpiSql,new Object[]{processid,jxOption.getId()});
        if (data.size()>0){
            k1= ((Map)data.get(0)).get("k1")==null?"" :((Map)data.get(0)).get("k1").toString();
            k2= ((Map)data.get(0)).get("k2")==null?"" :((Map)data.get(0)).get("k2").toString();
            k3= ((Map)data.get(0)).get("k3")==null?"" :((Map)data.get(0)).get("k3").toString();
            k4= ((Map)data.get(0)).get("k4")==null?"" :((Map)data.get(0)).get("k4").toString();
            k5= ((Map)data.get(0)).get("k5")==null?"" :((Map)data.get(0)).get("k5").toString();
            k6= ((Map)data.get(0)).get("k6")==null?"" :((Map)data.get(0)).get("k6").toString();

        }
    %>
    <tr>
        <td><%=jxOption.getObjname()%></td>
        <td><input id='k1_<%=jxOption.getId()%>' name='k1_<%=jxOption.getId()%>' value="<%=k1%>"></td>
        <td><input id='k2_<%=jxOption.getId()%>' name='k2_<%=jxOption.getId()%>' value="<%=k2%>"></td>
        <td><input id='k3_<%=jxOption.getId()%>' name='k3_<%=jxOption.getId()%>' value="<%=k3%>"></td>
        <td><input id='k4_<%=jxOption.getId()%>' name='k4_<%=jxOption.getId()%>' value="<%=k4%>"></td>
        <td><input id='k5_<%=jxOption.getId()%>' name='k5_<%=jxOption.getId()%>' value="<%=k5%>"></td>
    </tr>
    <%} %>

    <tr bgcolor="graytext">
        <td><%=i+++xy%></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
    </tr>
    <%for(Option xyOption:xyOptions){
    kpiSql="select * from ut_kpiscore where prjid=? and kid=?";
        List data=jdbcDao.queryForList(kpiSql,new Object[]{processid,xyOption.getId()});
    if (data.size()>0){
            k1= ((Map)data.get(0)).get("k1")==null?"" :((Map)data.get(0)).get("k1").toString();
            k2= ((Map)data.get(0)).get("k2")==null?"" :((Map)data.get(0)).get("k2").toString();
            k3= ((Map)data.get(0)).get("k3")==null?"" :((Map)data.get(0)).get("k3").toString();
            k4= ((Map)data.get(0)).get("k4")==null?"" :((Map)data.get(0)).get("k4").toString();
            k5= ((Map)data.get(0)).get("k5")==null?"" :((Map)data.get(0)).get("k5").toString();
            k6= ((Map)data.get(0)).get("k6")==null?"" :((Map)data.get(0)).get("k6").toString();

        }
    %>
    <tr>
        <td><%=xyOption.getObjname()%></td>
        <td><input id='k1_<%=xyOption.getId()%>' name='k1_<%=xyOption.getId()%>' value="<%=k1%>"></td>
        <td><input id='k2_<%=xyOption.getId()%>' name='k2_<%=xyOption.getId()%>' value="<%=k2%>"></td>
        <td><input id='k3_<%=xyOption.getId()%>' name='k3_<%=xyOption.getId()%>' value="<%=k3%>"></td>
        <td><input id='k4_<%=xyOption.getId()%>' name='k4_<%=xyOption.getId()%>' value="<%=k4%>"></td>
        <td><input id='k5_<%=xyOption.getId()%>' name='k5_<%=xyOption.getId()%>' value="<%=k5%>"></td>
    </tr>
    <%} %>
</table>
    </form>
<script type="text/javascript">
    document.getElementById('k6').value='<%=k6%>';
</script>
</body>
</html>